package com.ccx.coachsite.ui.login;

import android.app.Activity;
import android.view.View;
import android.widget.TextView;

public class TopViewUtil {

	public static void updateTitle(TextView view, String title) {
		if (view != null) {
			view.setText(title);
		}
	}
	
	public static void setTopBackVisable(Activity activity, int viewId, int visalbe) {
		View v = activity.findViewById(viewId);
		v.setVisibility(visalbe);
	}
	
	public static void setTopBackVisable(View view, int viewId, int visalbe) {
		View v = view.findViewById(viewId);
		v.setVisibility(visalbe);
	}
	
	public static void updateTopTitle(View view, int viewId, String title) {
		TextView v = (TextView) view.findViewById(viewId);
		updateTitle(v, title);
	}

	public static void updateTitle(Activity activity, int viewId, String title) {
		TextView view = (TextView) activity.findViewById(viewId);
		updateTitle(view, title);
	}
	
	public static void updateTitle(Activity activity, int viewId, int resourceId){
		TextView view = (TextView) activity.findViewById(viewId);
		String title = activity.getString(resourceId);
		updateTitle(view, title);
	}

	public static void updateRight(View view, int resourceId) {
		if (view != null) {
			view.setBackgroundResource(resourceId);
		}
	}

	public static void updateRight(Activity activity, int viewId, int resourceId) {
		View view = activity.findViewById(viewId);
		updateRight(view, resourceId);
	}
	
	public static void setRightVisable(Activity activity, int viewId, int visalbe) {
		View v = activity.findViewById(viewId);
		v.setVisibility(visalbe);
	}
	
	public static void setRightVisable(View view, int viewId, int visalbe) {
		View v = view.findViewById(viewId);
		v.setVisibility(visalbe);
	}
	
	public static void updateRight(View topView, int viewId, int resourceId) {
		View view = topView.findViewById(viewId);
		updateRight(view, resourceId);
	}
	
	public static void updateRightTitle(View vv, int viewId, String text) {
		View view = vv.findViewById(viewId);
		if (view == null) {
			return;
		}
		if (view instanceof TextView) {
			((TextView) view).setText(text);
		}
	}
	
	public static void updateRightTitle(Activity activity, int viewId, String text) {
		View view = activity.findViewById(viewId);
		if (view == null) {
			return;
		}
		if (view instanceof TextView) {
			((TextView) view).setText(text);
		}
	}

	public static void updateRightTitle(Activity activity, int viewId, int resource) {
		View view = activity.findViewById(viewId);
		if (view == null) {
			return;
		}
		if (view instanceof TextView) {
			((TextView) view).setText(activity.getString(resource));
		}
	}
}
